/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package domain.Entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author jorge
 */
@Entity
@Inheritance( strategy = InheritanceType.JOINED)
@Table(name = "usuario")
public class EntityUsuario implements Serializable {
    @Id
    @Column(name = "dni", nullable = false)
    private Long dni;
    @Column(name = "nombre", nullable = false)
    private String nombre;
    @Column(name = "contrasena")
    private String contrasena;
    @Column(name = "tipo")
    private String tipo;
    @Column(name = "email")
    private String email;
    @OneToOne(mappedBy = "eu", cascade = {CascadeType.REMOVE, CascadeType.PERSIST})
    private  EntityPerfil ep ;
    @OneToMany(targetEntity=domain.Entity.EntityInforme.class, mappedBy = "eu",cascade = CascadeType.REMOVE)
    private Collection ei;

    public Long getDni() {
        return dni;
    }

    public void setDni(Long dni) {
        this.dni = dni;
    }
    
    

    public Collection getEi() {
        return ei;
    }

    public void setEi(Collection ei) {
        this.ei = ei;
    }
    
    

    public EntityUsuario() {
    }

    public EntityUsuario(long dni) {
        this.dni = dni;
    }
    
    
    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getContrasena() {
        return contrasena;
    }

    public void setContrasena(String contrasena) {
        this.contrasena = contrasena;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public EntityPerfil getEp() {
        return ep;
    }

    public void setEp(EntityPerfil ep) {
        this.ep = ep;
    }
    
    
    

   @Override
    public int hashCode() {
        int hash = 0;
        hash += (dni != null ? dni.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EntityUsuario)) {
            return false;
        }
        EntityUsuario other = (EntityUsuario) object;
        if ((this.dni == null && other.dni != null) || (this.dni != null && !this.dni.equals(other.dni))) {
            return false;
        }
        return true;
    }
 

    
    
    @Override
    public String toString() {
        return "domain.Entity.EntityUsuario[dni=" + dni + "]";
    }

}
